<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品详情页面</title>
    <script type="text/javascript" src="asserts/plugins/JQuery/jquery-2.1.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#button_id").click(function () {
                $.ajax({
                    url: "ProductServlet",
                    data: {
                        action: "products",
                        // currentPage:"1",
                    },
                    type: "post",
                    dataType: "json",
                    success: function (respData) {
                        var str = '';
                        // alert(respData);
                        for (var i = 0; i < respData.length; i++) {
                            /*      var obj=respDate[i];
                                  // $("#pro_id").text("");
                                  alert(obj.pro_id+obj.class_id)
                                  console.log('id'+obj.id+'商品名'+obj.name)*/
                            //遍历Jeson所有数据；
                            str = "<tr>" +
                                "<td>" + respData[i].pro_id + "</td>" +
                                "+<td>" + respData[i].class_id + "</td>" +
                                "+<td>" + respData[i].name + "</td>" +
                                "+<td>" + respData[i].price + "</td>" +
                                "+<td>" + respData[i].status + "</td>" +
                                "+<td>" + respData[i].imgUrl + "</td>" +
                                "+<td>" + respData[i].detail + "</td>" +
                                "</tr>"

                            $("#table_id").append(str);

                        }
                    }
                })
            })
        })
    </script>
</head>
<body>
<table border="1" cellspacing="0" id="table_id">
    <tr id="tr_id">
        <th id="pro_id">pro_id</th>
        <th id="class_id">class_id</th>
        <th id="name">name</th>
        <th id="price">price</th>
        <th id="status">status</th>
        <th id="imgUrl">imgUrl</th>
        <th id="detail">detail</th>
    </tr>

</table>
<input type="button" id="button_id" value="展示所有商品">
</body>
</html>